package com.darrenchan.spark.sql

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.sql.SQLContext

/**
  * SQLContext的使用
  */
object SQLContextApp {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[2]").setAppName("SQLContextApp")
    val sc = new SparkContext(sparkConf)

    val sqlContext = new SQLContext(sc)

    //业务处理
    val people = sqlContext.read.format("json").load("people.json")

    people.printSchema()
    people.show()


    sc.stop()
  }
}
